﻿
/* Common JS function for getting a Json object through POST*/
function PostJsonObject(controler, action, xmlhttp, params) {
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.open("POST", "/" + controler + "/" + action, true);
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Content-length", params.length);
    // xmlhttp.setRequestHeader("Connection", "close");

    /**********IMPORTANT!!! - Need this on the header to identify whether the Request is an Ajax Request.IsAjax() on server side ***********/
    xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest"); //Need this Tag
    return xmlhttp;
}

// do not allow potentially dangerous characters as '<' and '>' to be entered
function AlphanumericValidation(evt) {
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
    if (charCode == 60 || charCode == 62 || charCode == 126) {
        return false;
    }

}

function RedirectToHome(ajaxData) {
    //alert(ajaxData);
    try {

        var data = ajaxData.get_response().get_object();
      //  alert(data.Status);
        if (data.Status == "0") {
            window.location.href = "/Default/Index";
        }

    } catch (e) {

    }
}

function BeginAjaxRequest() {  
    $('#ajaxLoader').show();
    $('#ajaxContent').hide();
}

function EndAjaxRequest() {
    $('#ajaxLoader').hide();
    $('#ajaxContent').show();
}
//Login action
